package com.cbarmstrong.MarketWatcher;

import java.io.Serializable;
import java.util.Vector;

import com.cbarmstrong.Finance.Indicator;
import com.cbarmstrong.Finance.TradeSet;

public class IndicatorChromosome extends IndicatorProcessor implements Serializable {

	private static final long serialVersionUID = 1L;
	private double fitness=0.0;
	
	//private ArrayList<String> indicators;
	
	public IndicatorChromosome(){
		//indicators=new ArrayList<String>();
	}
	
	@Override
	public TradeSet execute() {
		TradeSet ts = super.execute();
		if(ts.getProfit()<0){ setFitness(-1); }
		else{ setFitness(ts.tradeCount()*new Double(System.getProperty("tradeCountWeight", "1.0"))*ts.getProfit()/(ts.stdDev()*new Double(System.getProperty("deviationWeight", "1.0")))); }
		logger.finest("Profit: "+ts.getProfit()+", Dev: "+ts.stdDev()+", Fitness: "+fitness);
		return ts;
	}

	@Override
	public boolean addCrossIndicator(String s1, String s2) {
		return super.addCrossIndicator(s1, s2);
		//indicators.add(s1+" "+s2);
	}

	@Override
	public boolean addRangeIndicator(String s1, String s2, String series, int mode) {
		return super.addRangeIndicator(s1, s2, series, mode);
		//indicators.add(s1+" "+s2);
	}
	
	public Vector<Indicator> getIndicators(){
		return super.getInds();
	}
	
	private void setFitness(double f){ fitness=f; }
	
	public double getFitness(){ return fitness; }
	
}
